#include <stdio.h>

void swap(int* a,int*b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int ttt(int *a,int left,int right)
{
    int key = left;
    left = key+1;
    while(left<right)
    {
        while(left<right&&a[left]<a[key])left+=1;
        while(left<right&&a[right]>a[key]) right-=1;
        swap(&a[left],&a[right]);
    }
    swap(&a[key],&a[left]);
    return left;
}

void mysort(int* a,int left,int right)
{
    if(left>=right) return;
    int mid = ttt(a,left,right);
    mysort(a,left,mid-1);
    mysort(a,mid+1,right);
}

int main()
{
    int a[] = {9,8,7,6,5,4,3,2,1,0};
    mysort(a,0,9);
    for(int i = 0;i<10;++i) printf("%d ",a[i]);
    return 0;
}
